Skip to content

fix(toolkit): keep source DB intact when DbMove copy fails - #140

Closed
halibobo1205 wants to merge 1 commit into
developfrom
feature/dbmove-data-safety
Closed

fix(toolkit): keep source DB intact when DbMove copy fails#140
halibobo1205 wants to merge 1 commit into
developfrom
feature/dbmove-data-safety

Conversation

@halibobo1205

@halibobo1205 halibobo1205 commented Aug 4, 2026

Copy link
Copy Markdown
Owner

User description

Prevent the prior flow from deleting source databases after logging and ignoring per-file copy errors.

Preserve every source until all configured databases copy successfully. Roll back partial destinations, handle recursive database contents, and return a non-zero status on failure.

Finalize symlinks only after the copy phase completes, report completion once, and cover rollback and direct retry behavior in DbMoveTest.


CodeAnt-AI Description

Make database moves fail safely and preserve source data

What Changed

  • Failed moves now keep all source databases intact, remove partial destination copies when possible, and return a failure status for retry.
  • Database contents are copied recursively, including nested files and empty directories; symbolic links and unsupported entries stop the move without modifying their targets.
  • Source directories are replaced with symbolic links only after every database copies successfully. If finalization fails, the complete copy is kept and recovery instructions are shown.
  • Invalid destinations, including dangling symbolic links, are rejected before files are changed, and database options can be supplied in either order.
  • Database tool guidance now tells users to stop the FullNode service before operating on database files.

Impact

✅ Source databases preserved after failed moves
✅ No partial destination copies after copy errors
✅ Recursive database contents retained during moves

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Incremental review completed cc85dc5 Sep 03, 2026 · 08:35 08:36
✅ Incremental review completed 7315661 Sep 03, 2026 · 06:11 06:11
✅ Incremental review completed bce2891 Sep 02, 2026 · 06:09 06:09
✅ Incremental review completed 1123021 Sep 01, 2026 · 10:53 10:53
✅ Incremental review completed 6e2d1c1 Aug 27, 2026 · 07:40 07:40

@codeant-ai

codeant-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:XL This PR changes 500-999 lines, ignoring generated files label Aug 4, 2026
Comment thread plugins/src/main/java/common/org/tron/plugins/DbMove.java
@halibobo1205
halibobo1205 force-pushed the feature/dbmove-data-safety branch from e106186 to 6e2d1c1 Compare August 27, 2026 07:40
@codeant-ai

codeant-ai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added size:XL This PR changes 500-999 lines, ignoring generated files and removed size:XL This PR changes 500-999 lines, ignoring generated files labels Aug 27, 2026
@halibobo1205
halibobo1205 force-pushed the feature/dbmove-data-safety branch from 6e2d1c1 to 1123021 Compare September 1, 2026 10:53
@codeant-ai

codeant-ai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T08:39:32.860535Z cc85dc5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codeant-ai codeant-ai Bot removed the size:XL This PR changes 500-999 lines, ignoring generated files label Sep 1, 2026
@halibobo1205
halibobo1205 force-pushed the feature/dbmove-data-safety branch from 1123021 to eb05a4a Compare September 1, 2026 10:53
@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Sep 1, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb05a4a8fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/src/main/java/common/org/tron/plugins/DbMove.java
@halibobo1205
halibobo1205 force-pushed the feature/dbmove-data-safety branch 2 times, most recently from bce2891 to 7315661 Compare September 3, 2026 06:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7315661a1b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

AtomicBoolean hasError = new AtomicBoolean(false);
try (Stream<Path> files = Files.walk(p.original)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject destinations nested under their source

When a configured destination resolves beneath the source database, mkdirs() creates that destination before this recursive walk begins, so the walk can discover the directories that copyEntry() is generating and repeatedly copy the destination into itself until a path-length or disk-space failure occurs. Validate that p.destination does not start with p.original before starting the recursive copy.

Useful? React with 👍 / 👎.

Comment on lines +9 to +11
headerHeading = "All `db` tools operate directly on the database files.\n"
+ " Before performing a database operation,\n"
+ "you must stop the currently running FullNode service.\n",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Put the safety warning in the actual header

When users run Toolkit db --help, this warning is omitted: headerHeading is only the label preceding a non-empty header section, and this command does not define any header values, as described by picocli's Command API. Use header (or another rendered help section) so the newly added stop-FullNode warning is actually visible.

Useful? React with 👍 / 👎.

Prevent the prior flow from deleting source databases after logging and ignoring per-file copy errors.

Preserve every source until all configured databases copy successfully. Roll back partial destinations, handle recursive database contents, and return a non-zero status on failure.

Finalize symlinks only after the copy phase completes, report completion once, and cover rollback and direct retry behavior.
@halibobo1205
halibobo1205 force-pushed the feature/dbmove-data-safety branch from 7315661 to cc85dc5 Compare September 3, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant